<?php include_once './application/views/sys_admin/common/header.php';  ?>
<div class=" definewidth m20">
	<form class="form-inline definewidth m20">
		<button  type="button" class="btn btn-success"  onclick="href('/sys_admin/msgonline/add_view/<?php echo $type;?>');" >添加<?php echo $temp[$type];?></button>
	</form>
	<table class="table table-bordered table-hover definewidth m10">
		 <thead>
		    <tr>
		        <th><strong>序号</strong></th>
				<th><strong>应用场景</strong></th>
				<th><strong>标题</strong></th>
				<th><strong>创建时间</strong></th>
				<th><strong>状态</strong></th>
				<th><strong>操作</strong></th>
		    </tr>
		 </thead>
		     <?php foreach($templet_list as $key=>$tmp){?>
			  <tr id="row_<?php echo $tmp['id'];?>">
				<td><?php echo $tmp['id'];?></td>
				<td><?php echo $tmp['application_scene'];?></td>
				<td><?php echo $tmp['title'];?></td>
				<td><?php echo date('Y-m-d H:i',$tmp['add_time']);?></td>
				<td><?php if($tmp['is_stop'] == 1){echo '暂停';}else{echo '启用';}?></td>
				<td>
				<a href="javascript:;" onclick="templet(<?php echo $tmp['id'];?>);">浏览</a>
				<a href="/sys_admin/msgonline/edit_view/<?php echo $tmp['id'];?>">编辑</a>
				<?php if($tmp['is_stop'] !=1){?>
				<a href="javascript:if(confirm('确定暂停模板？')){msgstop(<?php echo $tmp['id'];?>);}">暂停</a>
				<?php }?>
				</td>
			  </tr>
			  <?php }?>
		  	<tr>
		  	<td colspan="6"  class="page"><?php echo $this->pagination->create_links();?></td>
		  	</tr>
	</table>
</div>

<div id="dialog" title="系统提示" style="display:none"><p id="msg" style="text-align:center"></p>
	<div id="msgonline_posts"></div>
</div>

<script>
function templet(id){
	$.ajax({
		type: "post",
		url: "/sys_admin/msgonline/view/",
		data: "id="+id,
		success: function(txt){
			$("#dialog" ).dialog({
				width:980,
				height:600,
				title:'模板信息',
				buttons:{"确定":function(){$(this).dialog("close");}},
			});
			txt = jQuery.trim(txt);
			txt = $(txt);
			$('#msgonline_posts').html(txt);
		},
	});
}

function msgstop(id){
	$.ajax({
		type: "post",
		url: "/sys_admin/msgonline/msgstop/",
		data: "id="+id,
		success: function(msg){
			$("#dialog" ).dialog();
			if(msg == 1){
				$("#msg").html("操作成功！");
				window.location.reload();
				//$("#row_"+id).hide();
			}else{
				$("#msg").html("操作失败，请联系管理员！");
			}
			setTimeout(function(){
				$("#dialog" ).dialog("close");
			},3000);
		},
		dataType: "text"
	});
}
</script>
